package cn.yy.cm;


import cn.yy.cm.service.UserService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 描述: 自定义CustomSpringMybatis
 *
 * @author: yanglin
 * @Date: 2021-11-29-9:53
 * @Version: 1.0
 */
public class CustomSpringMybatisT1 {

    /**
     * 将Mybatis中使用的类注入到spring中;
     *
     * 1.配置启动类注解MapperScam;扫描包路径注册BeanDefinition
     * 2.设置BeanDefinitionRegistrar注册类型过滤不验证注解Component;返回True;
     * 3.拿到Mapper对应BeanDefinition集合;修改BeanDefinition
     * 3.1.设置对应属性
     * 3.2.Mapper接口转为FactoryBean;生成对应代理类;
     * 3.2.重写isCandidateComponent();使Spring支持扫描接口;
     */

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(AppConfig.class);
        context.refresh();

        UserService userService = (UserService) context.getBean("userService");
        userService.queryUserList();
    }
}
